package com.dg11185.nearshop.baidumap;

import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.search.geocode.GeoCodeResult;
import com.baidu.mapapi.search.geocode.GeoCoder;
import com.baidu.mapapi.search.geocode.OnGetGeoCoderResultListener;
import com.baidu.mapapi.search.geocode.ReverseGeoCodeOption;
import com.baidu.mapapi.search.geocode.ReverseGeoCodeResult;

/**
 * 反地理位置编码 获取当前坐标下的街道名
 * 
 * @author：Daibo
 * @time：2014-6-9 下午4:52:16
 */
public class ReverseGeocode implements OnGetGeoCoderResultListener {
    private GeoCoder mSearch = null;

    private ReverseListener listener = null;

    public ReverseGeocode(ReverseListener listener) {
        mSearch = GeoCoder.newInstance();
        mSearch.setOnGetGeoCodeResultListener(this);

        this.listener = listener;
    }

    public void reverseGeoCode(LatLng poi) {
        mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(poi));
    }

    @Override
    public void onGetGeoCodeResult(GeoCodeResult arg0) {

    }

    @Override
    public void onGetReverseGeoCodeResult(ReverseGeoCodeResult arg0) {
        listener.onGetAddrResult(arg0.getAddress());

    }

    public interface ReverseListener {
        public void onGetAddrResult(String str);
    }
}
